# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Evan Teitelman <teitelmanevan at gmail dot com>
# Contributor: fxbru <frxbru[at]gmail>

pkgname=sqlmap
pkgver=1.7.10
pkgrel=1
pkgdesc='Automatic SQL injection and database takeover tool'
url='https://sqlmap.org'
arch=('any')
license=('GPL2')
depends=('python' 'sh')
optdepends=('perl: icmpsh extra tool')
backup=('etc/sqlmap.conf')
source=(https://github.com/sqlmapproject/sqlmap/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('7f33b10968d54b2100958548517c92c1891df0bcc682d28da35b853897d774b45f42aed8a642ffec46cbb9d11e6b5a5ce2038f2b012fc5251d0b71e39d8da097')
b2sums=('416aadc2b9fb75cf0a8735718515dc2d8ff8a24757aced159fa79fc2fe0040d5abf11fddaa9dbddcdd449aa0cb9b07630382f167acf0d45e8c9e34334d16e1a6')

build() {
  cd ${pkgname}-${pkgver}
  python -m compileall .
  python -O -m compileall .
}

package() {
  cd ${pkgname}-${pkgver}

  install -d "${pkgdir}/etc"
  install -d "${pkgdir}/usr/bin"
  install -d "${pkgdir}/opt/${pkgname}"
  install -d "${pkgdir}/usr/share/doc"

  mv doc "${pkgdir}/usr/share/doc/${pkgname}"
  mv sqlmap.conf "${pkgdir}/etc/sqlmap.conf"
  ln -sf /etc/sqlmap.conf "${pkgdir}/opt/${pkgname}/sqlmap.conf"
  cp -a --no-preserve=ownership * "${pkgdir}/opt/${pkgname}"

  cat > "${pkgdir}/usr/bin/sqlmap" << EOF
#!/bin/sh
cd /opt/${pkgname}
python sqlmap.py "\$@"
EOF
  cat > "${pkgdir}/usr/bin/sqlmapapi" << EOF
#!/bin/sh
cd /opt/${pkgname}
python sqlmapapi.py "\$@"
EOF

  chmod 755 "${pkgdir}/usr/bin/sqlmap"
  chmod 755 "${pkgdir}/usr/bin/sqlmapapi"
}

# vim: ts=2 sw=2 et:
